timeEvent

abstract fun timeEvent(@NonNull eventName: String)

Starts a timer for a specific event name to measure its duration.

When this method is called, the player records the current time as the start time for the given eventName. Later, when track or track is called for the same eventName, the elapsed time since this timeEvent call will be calculated. This duration, often referred to as "dwell time," is then automatically included as a property (e.g., "event_duration_ms") in the data sent with that track call.

Usage:

  1. Call timeEvent("my_custom_event") to start the timer.
  2. Perform actions related to "my_custom_event".
  3. Call track("my_custom_event") or track("my_custom_event", properties) to stop the timer and send the event along with its calculated duration.

Behavior Notes:

  • If timeEvent is called multiple times for the same eventName before a corresponding track call, typically the last call to timeEvent for that eventName will be used as the start time.
  • You can time multiple distinct event names concurrently.
  • If track(eventName) is invoked for an event that was not previously started with timeEvent(eventName), no duration property will be added.
  • Timed events are typically associated with the currently active event session (see newEventSession).

Parameters

eventName

The non-null name of the event to start timing. This name should match the eventName used in a subsequent track call to properly associate the duration.

See also

Throws

if eventName is null.

if eventName is empty.